package it.magazzinoCofi.view;





import it.magazzinocofi.settings.ColoriTenarisPrimary;

import java.awt.Color;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

public class UserLoginFrame extends BaseFrame{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3195545849264416333L;
	/**
	 * Field contentPane.
	 */
	private JPanel contentPane = new JPanel();;
	/**
	 * Field text_Nome.
	 */
	private JTextField text_Nome = new JTextField();;
	/**
	 * Field passwordField.
	 */
	private JPasswordField passwordField = new JPasswordField();
	/**
	 * Field btnLogin.
	 */
	private JButton btnLogin = new JButton("Login");
	/**
	 * Field lblNewLabel.
	 */
	private JLabel lblNewLabel = new JLabel("New label");
	/**
	 * Field lblNome.
	 */
	private JLabel lblNome = new JLabel("Codice operatore");
	/**
	 * Field lblPassword.
	 */
	private JLabel lblPassword = new JLabel("Password");

    /**
     * Riferimento a model, da verificare!!!!*********
     */
    //private DataUserModel m_model;

    public UserLoginFrame() {
		
    	System.out.println("[VIEW] Login View constructor");
		/**
		 * Riferimento al Modello
		 */
    	//this.m_model = model;
    	/**
    	 * il model implementa Observable, aggiungo al modello un osservatore (la view stessa)
    	 */
    	//this.m_model.addObserver(this);
		/**
		 * Immagine in alto a sinistra come icona
		 */
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(UserLoginFrame.class.getResource("/it/magazzinocofi/resources/apple-touch-icon.png")));
		/**
		 * Non si rende possibile cambiare la risoluzione del frame
		 */
		this.setResizable(false);
		/**
		 * Si setta il titolo
		 */
		this.setTitle("Gestione Magazzino COFI");
		/**
		 * Si esplicita la chiusura dell�applicazione alla chiusura del Frame
		 */
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setBounds(100, 100, 719, 461);
		this.contentPane.setBackground(Color.WHITE);
		this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		/**
		 * Si crea il contenitore
		 */
		this.setContentPane(this.contentPane);
		/**
		 * Setto la forma, font e bordi dei bottoni, label ecc
		 */
		this.btnLogin.setForeground(ColoriTenarisPrimary.GREEN355);
		this.btnLogin.setBounds(309, 292, 146, 37);
		this.btnLogin.setFont(new Font("Arial", Font.BOLD, 13));
		
		this.lblNewLabel.setBounds(181, 67, 376, 131);
		this.lblNewLabel.setIcon(new ImageIcon(UserLoginFrame.class.getResource("/it/magazzinocofi/resources/Tenaris_logo.JPG")));

		this.text_Nome.setBounds(343, 216, 86, 20);
		this.text_Nome.setColumns(10);
		
		this.lblNome.setBounds(231, 219, 94, 14);
		this.lblPassword.setBounds(272, 245, 61, 14);
		
		this.passwordField.setBounds(343, 247, 86, 20);
		
		this.contentPane.setLayout(null);
		this.contentPane.add(this.lblNome);
		this.contentPane.add(this.text_Nome);
		this.contentPane.add(this.lblPassword);
		this.contentPane.add(this.btnLogin);
		this.contentPane.add(this.lblNewLabel);
		this.contentPane.add(this.passwordField);
		
		//btnLogin.addActionListener(submitHandler);
	}
    
    /**
	 * Restituisce il nome immesso
	
	 * @return String */
    @Override
    public String getName() {
    	return this.text_Nome.getText();
    }
    
    
    
    public void addSubmitListener(ActionListener listenForSubmit){
    	btnLogin.addActionListener(listenForSubmit);
    }
   
    
    

}
